package com.gudy.counter.controller;

import com.gudy.counter.util.DbUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @GetMapping("/hello2")
    public String hello2(){
        redisTemplate.opsForValue().set("test:hello","hello word redis");

        return redisTemplate.opsForValue().get("test:hello");
    }

    @GetMapping("/hello")
    public String hello(){
        long id = DbUtil.getId();
        return id+"";
    }
}
